﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.ActiveRecord;
using System.ComponentModel.DataAnnotations;

namespace ZDSoft.LMS.Domain
{
    /// <summary>
    /// 客户，托运人和收货人都是客户
    /// </summary>
    [ActiveRecord("Client")]
    public class Client : EntityBase
    {
        //收货人名称
        [Property(NotNull = true, Length = 8)]
        [Required(ErrorMessage = "名称必填!")]
        [StringLength(8, MinimumLength = 0, ErrorMessage = "所填字符不得超过8个")]
        [Display(Name = "名称")]
        public string Name { get; set; }

        //收货人电话
        [Property(NotNull = true, Length = 12)]
        [Required(ErrorMessage = "电话必填!")]
        [StringLength(12, MinimumLength = 0, ErrorMessage = "字符不得超过12个")]
        [Display(Name = "电话")]
        public string Telephone { get; set; }

        //收货人地址
        [Property(NotNull = true, Length = 20)]
        [Required(ErrorMessage = "地址必填!")]
        [StringLength(20, MinimumLength = 0, ErrorMessage = "字符不得超过20个")]
        [Display(Name = "地址")]
        public string Address { get; set; }

        //收货人邮编
        [Property(NotNull = true, Length = 6)]
        [Required(ErrorMessage = "邮编必填!")]
        [StringLength(6, MinimumLength = 0, ErrorMessage = "字符不得超过6个")]
        [Display(Name = "邮编")]
        public string PostNumber { get; set; }

        //收货人Email
        [Property(NotNull = true, Length = 12)]//todo:
        [Required(ErrorMessage = "Email必填!")]
        [StringLength(12, MinimumLength = 0, ErrorMessage = "所填字符不得超过12个")]
        [Display(Name = "收货人Email")]
        public string Email { get; set; }

        [HasMany(typeof(TransportOrder), Table = "TransportOrder", ColumnKey = "ReceiverID",Lazy=true,Inverse = true)]//收货人与接单的关系（一对多）
        public IList<TransportOrder> ReceiveTransportOrder { get; set; }

        [HasMany(typeof(TransportOrder), Table = "TransportOrder", ColumnKey = "CommisionedorID", Lazy = true, Inverse = true)]//托运人人与接单的关系（一对多）
        public IList<TransportOrder> CommisionedeTransportOrder { get; set; }
    }
}
